package tests;

import java.util.concurrent.CountDownLatch;

public class test {

	public static CountDownLatch latch = new CountDownLatch(1);
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
//		ArrayList<Double> synAL = new ArrayList<Double>(1000000);
//		double [] synArr = new double[1000000];
//		
//		for(int i = 0; i < 1000000; i++) {
//			synAL.add(Math.random());
//			synArr[i] = Math.random();	
//		}
//		
//		long start = System.nanoTime();
//		
//		for(int i = 0, n = synArr.length; i < n; i++) {
//			synArr[i] = synArr[i] + 1;
//		}
//		long end = System.nanoTime();
//		System.out.println("Array: " + (end-start)/Math.pow(10, 9));
//		
//		start = System.nanoTime();
//		
//		for(Double d : synArr) {
//			d = d + 1;
//		}
//		
//		end = System.nanoTime();
//		
//		System.out.println("ArrayIter: " + (end-start)/Math.pow(10, 9));
//		System.out.println(synArr[0]);
//		start = System.nanoTime();
//		
//		int i = 0;
//		for(Double d : synAL) {
//			synAL.set(i++, d+1);
//		}
//		
//		end = System.nanoTime();
//		
//		System.out.println("ArrayList: " + (end-start)/Math.pow(10, 9));
//		System.out.println(synAL.get(0));
		
		
//		Synapse [] bob = new Synapse[1];
//		bob[0] = new Synapse(new LIFNeuron(true, 1), new LIFNeuron(true, 2));
//		Synapse s = bob[0];
//		s.setDecay(10000);
//		System.out.println(bob[0].getDecay());
		try {
		System.out.println(Thread.activeCount());
		Thread t = new Thread(new poop());
		t.start();
		System.out.println(Thread.activeCount());
		latch.await();	
		latch = new CountDownLatch(1);
		t = new Thread(new poop());
		t.start();
		System.out.println(Thread.activeCount());
		latch.await();
		System.out.println(Thread.activeCount());
		System.gc();
		System.out.println(Thread.activeCount());
		
		System.exit(0);
		
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private static class poop implements Runnable {
		
		public poop (){}
		
		public void run() {
			for(int i = 0; i < 100000; i++) {
				Math.exp(Math.random());
			}
			
			latch.countDown();
		}
		
	}
	
}
